{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Numpy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Numpy 数组基础\n",
    "1. 属性\n",
    "2. 索引\n",
    "3. 切片\n",
    "4. 变形\n",
    "5. 拼接&分裂"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 属性\n",
    "1. ndim 维度\n",
    "2. shape 每个维度的大小\n",
    "3. size 数组总大小"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "np.random.seed(42) # 设置随机数种子\n",
    "x1 = np.random.randint(10, size=6) # 一维数组\n",
    "x2 = np.random.randint(10, size=(3,4)) # 二维数组\n",
    "x3 = np.random.randint(10, size=(3,4,5)) # 三维数组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([6, 3, 7, 4, 6, 9])"
     },
     "metadata": {},
     "execution_count": 3
    }
   ],
   "source": [
    "x1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[2, 6, 7, 4],\n       [3, 7, 7, 2],\n       [5, 4, 1, 7]])"
     },
     "metadata": {},
     "execution_count": 4
    }
   ],
   "source": [
    "x2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[[5, 1, 4, 0, 9],\n        [5, 8, 0, 9, 2],\n        [6, 3, 8, 2, 4],\n        [2, 6, 4, 8, 6]],\n\n       [[1, 3, 8, 1, 9],\n        [8, 9, 4, 1, 3],\n        [6, 7, 2, 0, 3],\n        [1, 7, 3, 1, 5]],\n\n       [[5, 9, 3, 5, 1],\n        [9, 1, 9, 3, 7],\n        [6, 8, 7, 4, 1],\n        [4, 7, 9, 8, 8]]])"
     },
     "metadata": {},
     "execution_count": 5
    }
   ],
   "source": [
    "x3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "2"
     },
     "metadata": {},
     "execution_count": 7
    }
   ],
   "source": [
    "x2.ndim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "12"
     },
     "metadata": {},
     "execution_count": 11
    }
   ],
   "source": [
    "x2.size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "(3, 4)"
     },
     "metadata": {},
     "execution_count": 9
    }
   ],
   "source": [
    "x2.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "dtype('int64')"
     },
     "metadata": {},
     "execution_count": 10
    }
   ],
   "source": [
    "x3.dtype"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 索引\n",
    "获取单个元素"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "6"
     },
     "metadata": {},
     "execution_count": 12
    }
   ],
   "source": [
    "x1[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([6, 3, 7, 4, 6, 9])"
     },
     "metadata": {},
     "execution_count": 13
    }
   ],
   "source": [
    "x1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "6"
     },
     "metadata": {},
     "execution_count": 15
    }
   ],
   "source": [
    "x1[-2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[2, 6, 7, 4],\n       [3, 7, 7, 2],\n       [5, 4, 1, 7]])"
     },
     "metadata": {},
     "execution_count": 17
    }
   ],
   "source": [
    "x2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "1"
     },
     "metadata": {},
     "execution_count": 19
    }
   ],
   "source": [
    "x2[-1, -2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[[5, 1, 4, 0, 9],\n        [5, 8, 0, 9, 2],\n        [6, 3, 8, 2, 4],\n        [2, 6, 4, 8, 6]],\n\n       [[1, 3, 8, 1, 9],\n        [8, 9, 4, 1, 3],\n        [6, 7, 2, 0, 3],\n        [1, 7, 3, 1, 5]],\n\n       [[5, 9, 3, 5, 1],\n        [9, 1, 9, 3, 7],\n        [6, 8, 7, 4, 1],\n        [4, 7, 9, 8, 8]]])"
     },
     "metadata": {},
     "execution_count": 20
    }
   ],
   "source": [
    "x3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "0"
     },
     "metadata": {},
     "execution_count": 21
    }
   ],
   "source": [
    "x3[0, 1, 2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "x3[0, 1, 2] = 77.77"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[ 5,  1,  4,  0,  9],\n       [ 5,  8, 77,  9,  2],\n       [ 6,  3,  8,  2,  4],\n       [ 2,  6,  4,  8,  6]])"
     },
     "metadata": {},
     "execution_count": 35
    }
   ],
   "source": [
    "x3[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[[ 5,  1,  4,  0,  9],\n        [ 5,  8, 77,  9,  2],\n        [ 6,  3,  8,  2,  4],\n        [ 2,  6,  4,  8,  6]],\n\n       [[ 1,  3,  8,  1,  9],\n        [ 8,  9,  4,  1,  3],\n        [ 6,  7,  2,  0,  3],\n        [ 1,  7,  3,  1,  5]],\n\n       [[ 5,  9,  3,  5,  1],\n        [ 9,  1,  9,  3,  7],\n        [ 6,  8,  7,  4,  1],\n        [ 4,  7,  9,  8,  8]]])"
     },
     "metadata": {},
     "execution_count": 24
    }
   ],
   "source": [
    "x3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 切片\n",
    "获取子数组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([6, 3, 7, 4, 6, 9])"
     },
     "metadata": {},
     "execution_count": 27
    }
   ],
   "source": [
    "x1[0:6:1] # [)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([], dtype=int64)"
     },
     "metadata": {},
     "execution_count": 30
    }
   ],
   "source": [
    "x1[-1:1:1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([3, 4])"
     },
     "metadata": {},
     "execution_count": 29
    }
   ],
   "source": [
    "x1[1:-1:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([9, 6, 4, 7, 3, 6])"
     },
     "metadata": {},
     "execution_count": 31
    }
   ],
   "source": [
    "x1[::-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([], dtype=int64)"
     },
     "metadata": {},
     "execution_count": 32
    }
   ],
   "source": [
    "x1[1:-2:-1] # [-2:1:-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([6, 4, 7])"
     },
     "metadata": {},
     "execution_count": 33
    }
   ],
   "source": [
    "x1[-2:1:-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[2, 6, 7, 4],\n       [3, 7, 7, 2],\n       [5, 4, 1, 7]])"
     },
     "metadata": {},
     "execution_count": 47
    }
   ],
   "source": [
    "x2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "7"
     },
     "metadata": {},
     "execution_count": 40
    }
   ],
   "source": [
    "x2[1,1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "7"
     },
     "metadata": {},
     "execution_count": 39
    }
   ],
   "source": [
    "x2[1[1]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[3, 7, 7, 2]])"
     },
     "metadata": {},
     "execution_count": 48
    }
   ],
   "source": [
    "x2[1:-1][:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[3, 7]])"
     },
     "metadata": {},
     "execution_count": 4
    }
   ],
   "source": [
    "x2[1:-1, :2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[[ 5,  1,  4,  0,  9],\n        [ 5,  8, 77,  9,  2],\n        [ 6,  3,  8,  2,  4],\n        [ 2,  6,  4,  8,  6]],\n\n       [[ 1,  3,  8,  1,  9],\n        [ 8,  9,  4,  1,  3],\n        [ 6,  7,  2,  0,  3],\n        [ 1,  7,  3,  1,  5]],\n\n       [[ 5,  9,  3,  5,  1],\n        [ 9,  1,  9,  3,  7],\n        [ 6,  8,  7,  4,  1],\n        [ 4,  7,  9,  8,  8]]])"
     },
     "metadata": {},
     "execution_count": 36
    }
   ],
   "source": [
    "x3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[5, 1, 4, 0, 9]])"
     },
     "metadata": {},
     "execution_count": 5
    }
   ],
   "source": [
    "x3[:1, 0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 变形\n",
    "原始数组大小必须和变形后大小一致"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([6, 3, 7, 4, 6, 9])"
     },
     "metadata": {},
     "execution_count": 27
    }
   ],
   "source": [
    "x1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[6, 3, 7],\n       [4, 6, 9]])"
     },
     "metadata": {},
     "execution_count": 28
    }
   ],
   "source": [
    "x1.reshape((2,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[2, 6, 7, 4],\n       [3, 7, 7, 2],\n       [5, 4, 1, 7]])"
     },
     "metadata": {},
     "execution_count": 29
    }
   ],
   "source": [
    "x2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[2, 6],\n       [7, 4],\n       [3, 7],\n       [7, 2],\n       [5, 4],\n       [1, 7]])"
     },
     "metadata": {},
     "execution_count": 30
    }
   ],
   "source": [
    "x2.reshape((6,2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([6, 3, 7, 4, 6, 9])"
     },
     "metadata": {},
     "execution_count": 6
    }
   ],
   "source": [
    "x1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[6, 3, 7, 4, 6, 9]])"
     },
     "metadata": {},
     "execution_count": 9
    }
   ],
   "source": [
    "x11 = x1[np.newaxis, :]\n",
    "x11"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[6, 3, 7, 4, 6, 9]])"
     },
     "metadata": {},
     "execution_count": 12
    }
   ],
   "source": [
    "x1.reshape((1,6))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "(6,)"
     },
     "metadata": {},
     "execution_count": 10
    }
   ],
   "source": [
    "x1.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "(1, 6)"
     },
     "metadata": {},
     "execution_count": 11
    }
   ],
   "source": [
    "x11.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[6],\n       [3],\n       [7],\n       [4],\n       [6],\n       [9]])"
     },
     "metadata": {},
     "execution_count": 32
    }
   ],
   "source": [
    "x1[:, np.newaxis]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[6],\n       [3],\n       [7],\n       [4],\n       [6],\n       [9]])"
     },
     "metadata": {},
     "execution_count": 13
    }
   ],
   "source": [
    "x1.reshape((6,1))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 拼接和分裂"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([6, 3, 7, 4, 6, 9, 6, 3, 7, 4, 6, 9])"
     },
     "metadata": {},
     "execution_count": 4
    }
   ],
   "source": [
    "np.concatenate([x1,x1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "[2,6,7,4,2,6,7,4],\n",
    "[3,7,7,2,3,7,7,2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[2, 6, 7, 4],\n       [3, 7, 7, 2],\n       [5, 4, 1, 7],\n       [2, 6, 7, 4],\n       [3, 7, 7, 2],\n       [5, 4, 1, 7]])"
     },
     "metadata": {},
     "execution_count": 14
    }
   ],
   "source": [
    "np.concatenate([x2,x2], axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[2, 6, 7, 4, 2, 6, 7, 4],\n       [3, 7, 7, 2, 3, 7, 7, 2],\n       [5, 4, 1, 7, 5, 4, 1, 7]])"
     },
     "metadata": {},
     "execution_count": 15
    }
   ],
   "source": [
    "np.concatenate([x2,x2],axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[3, 7, 4, 6],\n       [2, 6, 7, 4],\n       [3, 7, 7, 2],\n       [5, 4, 1, 7]])"
     },
     "metadata": {},
     "execution_count": 16
    }
   ],
   "source": [
    "np.vstack([x1[1:-1], x2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([6, 3, 7, 4, 6, 9])"
     },
     "metadata": {},
     "execution_count": 17
    }
   ],
   "source": [
    "x1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "[array([6]), array([3, 7]), array([4]), array([6, 9])]"
     },
     "metadata": {},
     "execution_count": 18
    }
   ],
   "source": [
    "np.split(x1, [1,3,4])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Numpy 数组操作"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 用循环操作\n",
    "速度慢"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "range(0, 6)"
     },
     "metadata": {},
     "execution_count": 2
    }
   ],
   "source": [
    "range(6)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "values = [1,2,3,4,5]\n",
    "result = [1/1,1/2,1/3,1/4,1/5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([6, 3, 7, 4, 6, 9])"
     },
     "metadata": {},
     "execution_count": 6
    }
   ],
   "source": [
    "x1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def cal_reciprocals(values):\n",
    "    result = np.empty(len(values))\n",
    "    for i in range(len(values)):\n",
    "        result[i]=1/values[i]\n",
    "    return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([0.16666667, 0.33333333, 0.14285714, 0.25      , 0.16666667,\n       0.11111111])"
     },
     "metadata": {},
     "execution_count": 8
    }
   ],
   "source": [
    "1/x1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([0.16666667, 0.33333333, 0.14285714, 0.25      , 0.16666667,\n       0.11111111])"
     },
     "metadata": {},
     "execution_count": 5
    }
   ],
   "source": [
    "cal_reciprocals(x1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "513 ms ± 42.2 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
    }
   ],
   "source": [
    "big_array = np.random.randint(1, 100, size=1000000)\n",
    "%timeit cal_reciprocals(big_array)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "1.97 ms ± 167 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n"
    }
   ],
   "source": [
    "%timeit (1.0/big_array)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 通用函数\n",
    "```\n",
    "+  np.add\n",
    "-  np.subtract\n",
    "-  np.negative\n",
    "*  np.multiply\n",
    "/  np.divide\n",
    "// np.floor_divide\n",
    "** np.power\n",
    "%  np.mod\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([0., 0., 0., 0., 0.])"
     },
     "metadata": {},
     "execution_count": 11
    }
   ],
   "source": [
    "y11 = np.zeros(5)\n",
    "y11"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 指定输出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "y11[2] = 4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([ 64.,   0.,   8.,   0., 128.,   0.,  16.,   0.,  64.,   0., 512.,\n         0.])"
     },
     "metadata": {},
     "execution_count": 12
    }
   ],
   "source": [
    "y1 = np.zeros(12)\n",
    "np.power(2, x1, out=y1[::2])\n",
    "y1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([ 64.,   0.,   8.,   0., 128.,   0.,  16.,   0.,  64.,   0., 512.,\n         0.])"
     },
     "metadata": {},
     "execution_count": 14
    }
   ],
   "source": [
    "y2 = np.zeros(12)\n",
    "y2[::2] = 2 ** x1\n",
    "y2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 聚合"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "35"
     },
     "metadata": {},
     "execution_count": 4
    }
   ],
   "source": [
    "np.add.reduce(x1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "27216"
     },
     "metadata": {},
     "execution_count": 5
    }
   ],
   "source": [
    "np.multiply.reduce(x1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([ 6,  9, 16, 20, 26, 35])"
     },
     "metadata": {},
     "execution_count": 6
    }
   ],
   "source": [
    "np.add.accumulate(x1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([6, 3, 7, 4, 6, 9])"
     },
     "metadata": {},
     "execution_count": 16
    }
   ],
   "source": [
    "x1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 外积\n",
    "排列组合"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[ 1,  2,  3,  4,  5,  6,  7,  8,  9],\n       [ 2,  4,  6,  8, 10, 12, 14, 16, 18],\n       [ 3,  6,  9, 12, 15, 18, 21, 24, 27],\n       [ 4,  8, 12, 16, 20, 24, 28, 32, 36],\n       [ 5, 10, 15, 20, 25, 30, 35, 40, 45],\n       [ 6, 12, 18, 24, 30, 36, 42, 48, 54],\n       [ 7, 14, 21, 28, 35, 42, 49, 56, 63],\n       [ 8, 16, 24, 32, 40, 48, 56, 64, 72],\n       [ 9, 18, 27, 36, 45, 54, 63, 72, 81]])"
     },
     "metadata": {},
     "execution_count": 15
    }
   ],
   "source": [
    "x4 = np.array([1,2,3,4,5,6,7,8,9])\n",
    "np.multiply.outer(x4,x4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[ 2,  3,  4,  5,  6,  7,  8,  9, 10],\n       [ 3,  4,  5,  6,  7,  8,  9, 10, 11],\n       [ 4,  5,  6,  7,  8,  9, 10, 11, 12],\n       [ 5,  6,  7,  8,  9, 10, 11, 12, 13],\n       [ 6,  7,  8,  9, 10, 11, 12, 13, 14],\n       [ 7,  8,  9, 10, 11, 12, 13, 14, 15],\n       [ 8,  9, 10, 11, 12, 13, 14, 15, 16],\n       [ 9, 10, 11, 12, 13, 14, 15, 16, 17],\n       [10, 11, 12, 13, 14, 15, 16, 17, 18]])"
     },
     "metadata": {},
     "execution_count": 17
    }
   ],
   "source": [
    "np.add.outer(x4, x4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[36, 18, 42, 24, 36, 54],\n       [18,  9, 21, 12, 18, 27],\n       [42, 21, 49, 28, 42, 63],\n       [24, 12, 28, 16, 24, 36],\n       [36, 18, 42, 24, 36, 54],\n       [54, 27, 63, 36, 54, 81]])"
     },
     "metadata": {},
     "execution_count": 8
    }
   ],
   "source": [
    "np.multiply.outer(x1, x1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 统计"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "random_data = np.random.random(100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "46.815253987149944"
     },
     "metadata": {},
     "execution_count": 11
    }
   ],
   "source": [
    "np.sum(random_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "0.0005203769953158188"
     },
     "metadata": {},
     "execution_count": 12
    }
   ],
   "source": [
    "np.min(random_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "0.9977404850489419"
     },
     "metadata": {},
     "execution_count": 13
    }
   ],
   "source": [
    "np.max(random_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "0.0005203769953158188"
     },
     "metadata": {},
     "execution_count": 14
    }
   ],
   "source": [
    "random_data.min()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "0.2721130563341295"
     },
     "metadata": {},
     "execution_count": 15
    }
   ],
   "source": [
    "random_data.std()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([6, 3, 7, 4, 6, 9])"
     },
     "metadata": {},
     "execution_count": 18
    }
   ],
   "source": [
    "x1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "x5 = np.ones(6) # None Nan IEEE"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 广播"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([ 7.,  4.,  8.,  5.,  7., 10.])"
     },
     "metadata": {},
     "execution_count": 22
    }
   ],
   "source": [
    "x1 + x5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([ 9,  6, 10,  7,  9, 12])"
     },
     "metadata": {},
     "execution_count": 18
    }
   ],
   "source": [
    "x1 + 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[1., 1., 1.],\n       [1., 1., 1.],\n       [1., 1., 1.]])"
     },
     "metadata": {},
     "execution_count": 23
    }
   ],
   "source": [
    "a = np.array([0, 1, 2])\n",
    "M = np.ones((3, 3))\n",
    "M"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[1., 2., 3.],\n       [1., 2., 3.],\n       [1., 2., 3.]])"
     },
     "metadata": {},
     "execution_count": 20
    }
   ],
   "source": [
    "M + a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([0, 1, 2])"
     },
     "metadata": {},
     "execution_count": 21
    }
   ],
   "source": [
    "c = np.arange(3)\n",
    "c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[0],\n       [1],\n       [2]])"
     },
     "metadata": {},
     "execution_count": 22
    }
   ],
   "source": [
    "d = np.arange(3)[:, np.newaxis]\n",
    "d"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[0, 1, 2],\n       [1, 2, 3],\n       [2, 3, 4]])"
     },
     "metadata": {},
     "execution_count": 23
    }
   ],
   "source": [
    "c + d"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "(3, 3)"
     },
     "metadata": {},
     "execution_count": 24
    }
   ],
   "source": [
    "M.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "(3,)"
     },
     "metadata": {},
     "execution_count": 25
    }
   ],
   "source": [
    "a.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[1, 2, 3],\n       [1, 2, 3]])"
     },
     "metadata": {},
     "execution_count": 26
    }
   ],
   "source": [
    "e = np.array([[1,2,3],[1,2,3]])\n",
    "e"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "output_type": "error",
     "ename": "ValueError",
     "evalue": "operands could not be broadcast together with shapes (3,3) (2,3) ",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-27-ba8c605dd073>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mM\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mValueError\u001b[0m: operands could not be broadcast together with shapes (3,3) (2,3) "
     ]
    }
   ],
   "source": [
    "M + e"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([0.44234612, 0.69673548, 0.67240119, 0.37550431, 0.70788548,\n       0.58113345, 0.31358268, 0.35059293, 0.56409337, 0.49425353])"
     },
     "metadata": {},
     "execution_count": 26
    }
   ],
   "source": [
    "X.mean(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "5.833333333333333"
     },
     "metadata": {},
     "execution_count": 27
    }
   ],
   "source": [
    "x1.mean(axis=0) # 6, 3, 9, 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[0.42455498, 0.69643968, 0.2060437 ],\n       [0.82732826, 0.80116392, 0.46171428],\n       [0.43262266, 0.9495974 , 0.6349835 ],\n       [0.48729476, 0.21781215, 0.421406  ],\n       [0.80803375, 0.63323649, 0.68238618],\n       [0.86747419, 0.77020153, 0.10572464],\n       [0.08963333, 0.19327456, 0.65784016],\n       [0.33874789, 0.54327286, 0.16975803],\n       [0.89601673, 0.72087363, 0.07538974],\n       [0.7279045 , 0.45629523, 0.29856085]])"
     },
     "metadata": {},
     "execution_count": 24
    }
   ],
   "source": [
    "X = np.random.random((10, 3))\n",
    "X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([0.58996111, 0.59821675, 0.37138071])"
     },
     "metadata": {},
     "execution_count": 25
    }
   ],
   "source": [
    "Xmean = X.mean(axis=0)\n",
    "Xmean"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([[-0.04482883,  0.28057492,  0.14077351],\n       [-0.2270687 , -0.19499684, -0.00643576],\n       [ 0.25647344, -0.0665719 , -0.62140875],\n       [ 0.38749566, -0.01766587, -0.19983395],\n       [ 0.2846825 ,  0.26045223,  0.01763082],\n       [-0.34395599,  0.12621009, -0.0218009 ],\n       [-0.32447759, -0.24028296,  0.26458305],\n       [-0.03639172, -0.15440871,  0.2786684 ],\n       [ 0.41239174,  0.14305557,  0.16505105],\n       [-0.3643205 , -0.13636653, -0.01722747]])"
     },
     "metadata": {},
     "execution_count": 33
    }
   ],
   "source": [
    "Xcentered = X - Xmean\n",
    "Xcentered"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([ 0.00000000e+00, -1.11022302e-17, -1.33226763e-16])"
     },
     "metadata": {},
     "execution_count": 34
    }
   ],
   "source": [
    "Xcentered.mean(0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 布尔操作\n",
    "1. 全数据布尔操作\n",
    "2. 统计量布尔操作\n",
    "3. 数据取值过程布尔操作（掩码）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([6, 3, 7, 4, 6, 9])"
     },
     "metadata": {},
     "execution_count": 39
    }
   ],
   "source": [
    "x1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([False,  True, False,  True, False, False])"
     },
     "metadata": {},
     "execution_count": 36
    }
   ],
   "source": [
    "x1 < 6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([False,  True, False,  True, False,  True])"
     },
     "metadata": {},
     "execution_count": 43
    }
   ],
   "source": [
    "(x1 < 6) | (x1 > 8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "2"
     },
     "metadata": {},
     "execution_count": 28
    }
   ],
   "source": [
    "np.sum(x1 < 6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([6, 3, 7, 4, 6, 9])"
     },
     "metadata": {},
     "execution_count": 31
    }
   ],
   "source": [
    "x1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "True"
     },
     "metadata": {},
     "execution_count": 29
    }
   ],
   "source": [
    "np.any(x1 > 7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([6, 3, 4, 6])"
     },
     "metadata": {},
     "execution_count": 32
    }
   ],
   "source": [
    "x1[x1 <= 6]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([3, 7, 4])"
     },
     "metadata": {},
     "execution_count": 35
    }
   ],
   "source": [
    "x1[1:4]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 花哨索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([3, 9, 4])"
     },
     "metadata": {},
     "execution_count": 41
    }
   ],
   "source": [
    "x1[[1,5,3]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([0.84666114, 0.85632429, 0.40450813, 0.8877701 , 0.85092845,\n       0.93563499, 0.78534065, 0.66898825, 0.58068662, 0.37228277,\n       0.94013344, 0.97366384, 0.28392097, 0.30536386, 0.48561375,\n       0.44842414, 0.99445746, 0.17592525, 0.01807536, 0.49389372,\n       0.17882271, 0.36646878, 0.74417052, 0.72093992, 0.30806079,\n       0.54254023, 0.50881408, 0.63633262, 0.25046182, 0.58987085,\n       0.97889286, 0.48674215, 0.90609879, 0.43439437, 0.35007841,\n       0.64510336, 0.66892406, 0.86416757, 0.23018527, 0.49919338,\n       0.5720042 , 0.76855401, 0.04360377, 0.99455051, 0.46994451,\n       0.27956034, 0.88349402, 0.74771877, 0.95307185, 0.3307503 ,\n       0.55276497, 0.57229247, 0.98033158, 0.07534626, 0.30569702,\n       0.19091103, 0.26847486, 0.48527987, 0.37268687, 0.39469147,\n       0.84421314, 0.93001683, 0.07041613, 0.20891872, 0.67114352,\n       0.35864678, 0.25416365, 0.29529059, 0.32255076, 0.84866979,\n       0.13662133, 0.708911  , 0.55281998, 0.29651014, 0.41978086,\n       0.25620694, 0.61151371, 0.08159418, 0.00518486, 0.62789441,\n       0.19427395, 0.07094092, 0.39678383, 0.05076853, 0.88661715,\n       0.02761677, 0.5788649 , 0.43847412, 0.67202614, 0.32815267,\n       0.15504162, 0.98184089, 0.8389335 , 0.86040462, 0.25025136,\n       0.03883473, 0.30326551, 0.53708243, 0.32665124, 0.827869  ])"
     },
     "metadata": {},
     "execution_count": 47
    }
   ],
   "source": [
    "X = np.random.random(100)\n",
    "X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([59,  4, 67,  5, 95, 93, 46, 98, 54, 39, 51, 15, 12, 29, 18, 16, 62,\n       18, 91, 57])"
     },
     "metadata": {},
     "execution_count": 48
    }
   ],
   "source": [
    "index = np.random.randint(0, 99, 20)\n",
    "index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([0.39469147, 0.85092845, 0.29529059, 0.93563499, 0.03883473,\n       0.86040462, 0.88349402, 0.32665124, 0.30569702, 0.49919338,\n       0.57229247, 0.44842414, 0.28392097, 0.58987085, 0.01807536,\n       0.99445746, 0.07041613, 0.01807536, 0.98184089, 0.48527987])"
     },
     "metadata": {},
     "execution_count": 49
    }
   ],
   "source": [
    "X[index] # X[[59,4,67,...]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "array([81, 65,  5, 29, 14, 40, 72, 52, 42, 48, 20, 45, 24, 84, 43, 59,  6,\n       94, 78, 85])"
     },
     "metadata": {},
     "execution_count": 50
    }
   ],
   "source": [
    "index = np.random.choice(X.shape[0], 20, replace=False)\n",
    "index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python37464bitbaseconda2e78d15030274c12b31e6e05ecc04132",
   "display_name": "Python 3.7.4 64-bit ('base': conda)"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}